package com.uziot.activiti6.common.util;

import com.greenpineyu.fel.FelEngine;
import com.greenpineyu.fel.FelEngineImpl;
import com.greenpineyu.fel.context.FelContext;

import java.util.Map;

/**
 * @author shidt
 * @version V1.0
 * @className FelSupport
 * @date 2021-02-26 10:38:41
 * @description EL表达式解析判定，注意比较大小等逻辑时，类型的判定
 */

public class FelSupport {

    public static Object result(Map<String, Object> map, String expression) {
        FelEngine fel = new FelEngineImpl();
        FelContext ctx = fel.getContext();

        for (Map.Entry<String, Object> entry : map.entrySet()) {
            ctx.set(entry.getKey(), entry.getValue());
        }
        return fel.eval(expression);
    }
}
